package com.abso.sunlight.explorer;

import java.util.List;

import com.abso.sunlight.api.Legislator;
import com.abso.sunlight.api.LegislatorQuery;

/**
 * Objects of this class holds information about a specific query, including a unique name and a set of results.
 */
public class LegislatorSearch {

    /** The name assigned to the search. */
    private String name;

    /** The query configuration. */
    private LegislatorQuery query;

    /** The list of legislators satisfying the query criteria. */
    private List<Legislator> result;

    /** If <code>true</code> the search name and query have been previosuly saved into the persistent store. */
    private boolean saved;

    /**
     * Returns the name assigned to the search.
     * 
     * @return the name assigned to the search.
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name of the search.
     * 
     * @param name
     *            a unique name for the search.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Returns the query configuration.
     * 
     * @return the query configuration.
     */
    public LegislatorQuery getQuery() {
        return query;
    }

    /**
     * Sets the query configuration.
     * 
     * @param query
     *            the query configuration.
     */
    public void setQuery(LegislatorQuery query) {
        this.query = query;
    }

    /**
     * Returns the list of results, or <code>null</code> if the search never run.
     * 
     * @return the list of legislators satisfying the criteria.
     */
    public List<Legislator> getResult() {
        return result;
    }

    /**
     * Sets the list of legislators satisfying the criteria, as returned by invoking the remote Sunlight service.
     * 
     * @param result
     *            the list of legislators.
     */
    public void setResult(List<Legislator> result) {
        this.result = result;
    }

    /**
     * Sets if the query is saved, i.e. if the query is saved in the persistent store.
     * 
     * @param saved   <code>true</code> if the query is saved.
     */
    public void setSaved(boolean saved) {
        this.saved = saved;
    }

    /**
     * Returns if the query is saved, i.e. if the query is saved in the persistent store.
     * 
     * @return   if the query is saved.
     */
    public boolean isSaved() {
        return saved;
    }

}
